
const path = require('path')
const webpack = require('webpack')
const HtmlWebpacklugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')

const config = {
  mode: 'none',
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    rules: [{
      test: /\.css$/,
      use: ['style-loader', 'css-loader']
    }, {
      test: /\.less$/,
      use: ['style-loader', 'css-loader', 'less-loader']
    }, {
      test: /\.vue$/,
      use: 'vue-loader'
    }, {
      test: /\.vue$/,
      exclude: /node_modules/,
      use: 'eslint-loader',
      enforce: 'pre'
    }, {
      test: /\.(png|jpe?g|gif)$/,
      use: {
        loader: 'url-loader',
        options: {
          limit: 4 * 1024,
          outputPath: 'images/',
          esModule: false
        }
      }
    }]
  },
  plugins: [
    new VueLoaderPlugin(),
    new CleanWebpackPlugin(),
    new HtmlWebpacklugin({
      template: './public/index.html',
      title: 'vue webpack',
    }),
    new webpack.DefinePlugin({
      BASE_URL: '"/"'
    })
  ]
}

module.exports = config